package com.xxl.job.executor.core.utils;

import com.alibaba.fastjson.JSON;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.xxl.job.executor.core.entity.AddAiCheckEventCountMQ;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Producer {
    public static void main(String[] args) throws Exception {
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("117.158.15.170");
        connectionFactory.setPort(5672);
        connectionFactory.setUsername("test");
        connectionFactory.setPassword("123456");
        Connection connection = connectionFactory.newConnection();
        Channel channel = connection.createChannel();
        String LaneNo = "1";
        AddAiCheckEventCountMQ addAiCheckEventCountMQ = new AddAiCheckEventCountMQ();
        addAiCheckEventCountMQ.setStartTime(new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
        addAiCheckEventCountMQ.setEndTime(new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
        addAiCheckEventCountMQ.setLaneNo(Integer.valueOf(LaneNo));
        addAiCheckEventCountMQ.setArrivalFlow(100);
        addAiCheckEventCountMQ.setLightVehicle(35);
        addAiCheckEventCountMQ.setHeavyVehicle(20);
        addAiCheckEventCountMQ.setAveSpeed(20);
        addAiCheckEventCountMQ.setTimeDistance(20);
        addAiCheckEventCountMQ.setSpaceDistance(1);
        addAiCheckEventCountMQ.setSpaceOccupyRation(new BigDecimal(18.35).setScale(2, BigDecimal.ROUND_HALF_UP));
        addAiCheckEventCountMQ.setTimeOccupyRation(new BigDecimal(18.35).setScale(2, BigDecimal.ROUND_HALF_UP));
        addAiCheckEventCountMQ.setQueueLength(35);
        addAiCheckEventCountMQ.setStationId("HA5027");
        addAiCheckEventCountMQ.setStationName("内乡县非现场执法点");
        addAiCheckEventCountMQ.setStationCode("41132504");
        String message = JSON.toJSONString(addAiCheckEventCountMQ);
        String exchange = "sjlw.ai.exchange";
        String routingKey = "统计信息";
        channel.basicPublish(exchange, routingKey, true, null, message.getBytes());
    }
}